package edu.friday.controller;

import edu.friday.common.base.BaseController;
import edu.friday.common.result.RestResult;
import edu.friday.common.result.TableDataInfo;
import edu.friday.model.vo.SysUserVo;
import jakarta.validation.Valid;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/demo")
public class DemoController extends BaseController {
    @GetMapping(value = {"/","/{userId}"})
    public RestResult getInfo(@PathVariable(value = "userId",required = false) long userId){
        RestResult ajax=RestResult.success();
        ajax.put("userId",userId);
        return ajax;
    }
    @GetMapping("/list")
    public TableDataInfo list(){
        List<String > list=new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");

        TableDataInfo a = TableDataInfo.success(list,100);
        a.setMsg(1);

        return a;
    }

    @GetMapping("/valid")
    public RestResult valid(@Valid SysUserVo sysUserVo){

        return RestResult.success();
    }
}
